from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class gui_fake :
    def __init__ ( self ) :
        self . _label = None
        self . _received_set_label_text_args = None
        self . _gui_create_label_request = None
    def gui_create_label_request ( self , master , text , borderwidth , relief , anchor ) :
        self . _gui_create_label_request = [ self . _label , master , text , borderwidth , relief , anchor ]
    def gui_set_label_text ( self , label , text ) :
        self . _received_set_label_text_args = [ label , text ]

class mediator_gui_label_tests : 
    'mediator_gui_label'
    def __init__ ( self , test ) :
        self . _test = test
        self . _gui = gui_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'gui' 
            , self . _gui 
            , None
            ) )
    def test_gui_create_label_request ( self ) :
        self . _gui . _label = 'my label'
        self . _mediator . gui_create_label_request ( 'my master' , 'my text' , 'my borderwidth' , 'my relief' , 'my anchor' )
        self . _test . assume_equal ( self . _gui . _gui_create_label_request ,
            [ 'my label'
            , 'my master'
            , 'my text'
            , 'my borderwidth'
            , 'my relief'
            , 'my anchor'
            ] )
    def test_gui_create_label_request_default_args ( self ) :
        self . _gui . _label = 'my label'
        self . _mediator . gui_create_label_request ( 'my master' , 'my text' )
        self . _test . assume_equal ( self . _gui . _gui_create_label_request ,
            [ 'my label'
            , 'my master'
            , 'my text'
            , None
            , None
            , None
            ] )
    def test_gui_create_label_request_named_args ( self ) :
        self . _gui . _label = 'my label'
        self . _mediator . gui_create_label_request \
            ( master = 'my master' 
            , text = 'my text' 
            , borderwidth = 'my borderwidth' 
            , relief = 'my relief' 
            , anchor = 'my anchor'
            )
        self . _test . assume_equal ( self . _gui . _gui_create_label_request ,
            [ 'my label'
            , 'my master'
            , 'my text'
            , 'my borderwidth'
            , 'my relief'
            , 'my anchor'
            ] )
    def test_gui_set_label_text ( self ) :
        self . _mediator . gui_set_label_text ( 'my label' , 'my text' )
        self . _test . assume_equal ( self . _gui . _received_set_label_text_args , 
            [ 'my label' 
            , 'my text'
            ] )
